package com.rdd.wordcount

import org.apache.spark.{SparkConf, SparkContext}

object wcBli {

  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setAppName("wc").setMaster("local")
    val sc = new SparkContext(conf)

    val text = sc.textFile("e:\\aaa.txt")
    val line = text.flatMap(x => (x.split(" ")))
    val word = line.map(x => (x, 1))
    word.reduceByKey((x, y) => (x + y)).foreach(println)

//    sc.textFile("e:\\aaa.txt").flatMap(_.split(" ")).map((_, 1)).reduceByKey(_+_).foreach(println)

    sc.stop()
  }

}
